package com.ren.fileuploadanddownload.configs;

import com.ren.fileuploadanddownload.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/*
拦截器配置类，相当于 .xml
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    //用来加入拦截器相关配置

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加哪个拦截器
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/file/**")//拦截所有控制器的请求
                .excludePathPatterns("/index")//排除指定的请求
                .excludePathPatterns("/js/**","/css/**","/img/**");//排除样式、脚本、图片等资源文件

    }
}
